﻿@model CNDreams.Web.Models.ModelHomeIndex
@{
	Layout = null;
}
@{
	var oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
	string jsonMenu = oSerializer.Serialize(SessionManager.CurrentSysUserMenus.OrderBy(x => x.OrderIndex));
}
<!DOCTYPE html>
<html>
<head>
	@RazorWidget.ViewStart()
	<base target="mainFrame" />
	<title>西安高新区公租房管理系统</title>
	<link href="/Content/home.css" rel="stylesheet" type="text/css" />
	<script src="/Scripts/base/home.js" type="text/javascript"></script>
	<script type="text/javascript">
		var menus = eval('(@Html.Raw(jsonMenu))');
		function loginOut() {
			top.window.$("#sysConfirm").html("确认要退出么？");
			top.window.$("#sysConfirm").dialog({
				resizable: false,
				height: 200,
				title: "系统提示",
				modal: true,
				buttons: {
					"是": function () {
						$.ajax({
							type: "POST",
							url: "/ModuleLogin/login/loginout",
							data: "",
							success: function (msg) {
								msg = eval("(" + msg + ")");
								if (msg.result == "") {
									window.location = "/modulelogin/login";
								}
								else {
									sysAlert(msg.result);
								}
							}
						});
						top.window.$("#sysConfirm").dialog("close");
					},
					"否": function () {
						top.window.$("#sysConfirm").dialog("close");
					}
				}
			});
		}

		/* 一级菜单点击事件
		----------------------------------------------------------*/
		function topMenuClick(menu) {
			var menuContent = "";
			for (var i = 0; i < menus.length; i++) {
				if (menus[i].ParentID != menu)
					continue;
				menuContent += "<li>"
									+ "<div class='second-level-menu'>"
									+ "<img alt='' src='/content/images/Menu/{0}' />"
										+ "<span>{1}</span>"
										+ "<span class='arrow'>&nbsp;</span>"
									+ "</div>"
									+ "<dl>"
										+ "{2}"
									+ "</dl>"
								+ "</li>";
				var menuLevel2 = "";
				for (var j = 0; j < menus.length; j++) {
					if (menus[j].ParentID != menus[i].ID)
						continue;
					menuLevel2 += "<dd>"
									+ "<a onclick=\"javascript:setframeUrl('{0}','{1}')\" href='javascript:void(0)'>"
										+ "<img alt='' src='/content/images/Menu/{2}' />"
										+ "<span>{3}</span>"
									+ "</a>"
								+ "</dd>";
					menuLevel2 = String.format(menuLevel2, menus[j].TargetURL, menus[i].Name + " >> " + menus[j].Name, menus[j].Icon, menus[j].Name);
				}
				menuContent = String.format(menuContent, menus[i].Icon, menus[i].Name, menuLevel2);
			}
			$(".container-menu").html(menuContent);
			$(".container-menu").hide();
			$(".container-menu").show("slide");
			loadMenu();
			/* 把所有标签改成非活动
			----------------------------------------------------------*/
			var activeTab = $(".menu-active");
			var zIndex = activeTab.css("z-index") / 10;
			activeTab.css("z-index", zIndex);
			activeTab.attr("class", "menu-inactive");

			/* 显示活动标签
			----------------------------------------------------------*/
			var objSelectedLevel1Menu = $("#" + menu);
			if (objSelectedLevel1Menu.attr("class") == "menu-active") {
				return;
			}
			else {
				objSelectedLevel1Menu.attr("class", "menu-active");
				zIndex = objSelectedLevel1Menu.css("z-index") * 10;
				objSelectedLevel1Menu.css("z-index", zIndex);
			}

			/* 提醒页面更新
			----------------------------------------------------------*/
			$("#mainFrame").attr("src", "/home/main?level1=" + menu);
		}
		function homeClick() {
			var activeTab = $(".menu-active");
			activeTab.click();
		}
		//修改密码
		function resetPassword() {
			window.top.openDialog({ Url: "/Home/ChangePassword/", Title: "密码修改", Width: 400, Height: 320 });
		}
	</script>
</head>
<body>
	<div class="menu-toggle">
	</div>
	<table class="container" cellpadding="0" cellspacing="0">
		<tr class="container-top">
			<td>
				<div class="short-menu">
					<ul>
						<li><a href="javascript:void(0);" class="home" id="tdHome" onclick="javascript:homeClick();">
						</a></li>
						<li><a href="javascript:void(0);" class="password" id="tdPassword" onclick="javascript:resetPassword()">
						</a></li>
						<li><a href="javascript:void(0);" class="help" onclick="javascript:window.open('/Help/西安公租房用户手册.htm')"></a></li>
						<li><a href="javascript:void(0);" onclick="loginOut()" class="reset"></a></li>
					</ul>
				</div>
				<!--加载一级菜单-->
				<ul class="top-level-menu">
					@{
						var topLevelMenu = SessionManager.CurrentSysUserMenus.Where(x => x.Level == 1).OrderBy(x => x.OrderIndex).ToList();
						var zIndexInit = 90;
						var zIndex = 900;
					}
					@for (int i = 0; i < topLevelMenu.Count(); i++)
	 {
		 if (i != 0)
		 {
			 zIndex = zIndexInit;
		 }
						<li onclick="javascript:topMenuClick('@(topLevelMenu[i].ID)');return false;" style="z-index:@(zIndex); left:@(i * 122)px;" class="@(i == 0 ? "menu-active" : "menu-inactive")" id="@(topLevelMenu[i].ID)">
							<table>
								<tr>
									<td class="left">
									</td>
									<td class="middle">@(topLevelMenu[i].Name)
									</td>
									<td class="right">
									</td>
								</tr>
							</table>
						</li>
		 zIndexInit = zIndexInit - 1;
	 }
				</ul>
				<!--加载欢迎信息-->
				<div class="welcome">
					您好:<span style="color: #B6EFFD; font-size: 12px">@SessionManager.CurrentSysUser.UserName</span>!&nbsp;&nbsp;&nbsp;
					<span style="color: #B6EFFD; font-size: 12px">@DateTime.Now.ToString("yyyy年MM月dd日")
						@System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek)</span>
				</div>
			</td>
		</tr>
		<tr valign="top">
			<td valign="top">
				<table class="main-content" cellpadding="0" cellspacing="0">
					<tr>
						<td class="main-left" style="display: none;">
							<!--加载二级、三级菜单-->
							<ul class="container-menu" style="display: none;">
								@{
									var level2 = SessionManager.CurrentSysUserMenus.Where(x => x.ParentID == topLevelMenu[0].ID).OrderBy(x => x.OrderIndex).ToList();
								}
								@for (int i = 0; i < level2.Count; i++)
		{
									<li>
										<div class="second-level-menu">
											<img alt="" src="/content/images/Menu/@(level2[i].Icon)" />
											<span>@(level2[i].Name)</span> <span class="arrow">&nbsp;</span>
										</div>
										<dl>
											@{
			var level3 = SessionManager.CurrentSysUserMenus.Where(x => x.ParentID == level2[i].ID).OrderBy(x => x.OrderIndex).ToList();
											}
											@for (int j = 0; j < level3.Count; j++)
		   {
												<dd>
													<a onclick="javascript:setframeUrl('@(level3[j].TargetURL)','@(level2[i].Name + " >> " + level3[j].Name)')" href="javascript:void(0)">
														<img alt="" src="/content/images/Menu/@(level3[j].Icon)" />
														<span>@(level3[j].Name)</span> </a>
												</dd>
		   }
										</dl>
									</li>
		}
							</ul>
						</td>
						<td class="main-right">
							<div class="navigation">
								<span>首页</span> <a onclick="history.back(-1);" href=" javascript:void(0);"></a>
							</div>
							<iframe id='mainFrame' name='mainFrame' frameborder='0' width='100%' src='/home/main?level1=@(topLevelMenu.Count > 0 ? topLevelMenu[0].ID : Guid.Empty)'>
							</iframe>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	<div>
		<div id="dialog1" style="display: none; overflow: hidden;">
			<iframe id="iframeDialog1" name="iframeDialog1" src='' frameborder='0' width='100%'
				height='100%' marginheight='0' marginwidth='0' scrolling='no'></iframe>
		</div>
		<div id="dialog2" style="display: none; overflow:hidden;">
			<iframe id="iframeDialog2" name="iframeDialog2" src='' frameborder='0' width='100%'
				height='100%' marginheight='0' marginwidth='0' scrolling='no'></iframe>
		</div>
		<div id="dialog3" style="display: none; overflow: hidden;">
			<iframe id="iframeDialog3" name="iframeDialog3" src='' frameborder='0' width='100%'
				height='100%' marginheight='0' marginwidth='0' scrolling='no'></iframe>
		</div>
		<div id="dialog4" style="display: none; overflow: hidden;">
			<iframe id="iframeDialog4" name="iframeDialog4" src='' frameborder='0' width='100%'
				height='100%' marginheight='0' marginwidth='0' scrolling='no'></iframe>
		</div>
		<div id="sysMessage" class="success" style="display: none;">
			系统消息--操作成功
		</div>
		<div id="sysAlert" class="info" style="display: none;">
			系统消息--操作失败
		</div>
		<div id="sysConfirm" class="info" style="display: none;">
			系统消息--提示操作
		</div>
	</div>
</body>
</html>
